package com.jasperwireless.api.ws.client;

import java.rmi.RemoteException;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;

import com.jasperwireless.api.ws.schema.GetTerminalDetailsRequest;
import com.jasperwireless.api.ws.schema.GetTerminalDetailsResponse;
import com.jasperwireless.api.ws.schema.Iccids_type3;
import com.jasperwireless.api.ws.schema.TerminalServiceStub;

public class test {
	public static OMElement createHeaderOMElement(){
		  OMFactory factory = OMAbstractFactory.getOMFactory();
		     OMNamespace SecurityElementNamespace = factory.createOMNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse"); 
		     OMElement authenticationOM = factory.createOMElement("Security",
		                SecurityElementNamespace);
		        
		        OMElement UsernameToken = factory.createOMElement("UsernameToken",
		                SecurityElementNamespace);
		        OMElement usernameOM = factory.createOMElement("Username",
		                SecurityElementNamespace);
		        OMElement passwordOM = factory.createOMElement("Password",
		                SecurityElementNamespace);
		        usernameOM.setText("wangyuxi");
		        passwordOM.setText("wangyuxi");
		        authenticationOM.addChild(UsernameToken);
		        UsernameToken.addChild(usernameOM);
		        UsernameToken.addChild(passwordOM);
		        return authenticationOM;
		 }
	
	
	public static void main(String[] args) throws RemoteException {
		TerminalServiceStub stub = new TerminalServiceStub();
		stub._getServiceClient().addHeader(createHeaderOMElement());
		
		GetTerminalDetailsRequest request = new GetTerminalDetailsRequest();
		request.setMessageId("asdasdasdas");
		request.setLicenseKey("d328ebf9-1542-491e-9a48-099b3abb4d67");
		Iccids_type3 iccids = new Iccids_type3();
		iccids.addIccid("89860117750005477048");
		request.setIccids(iccids);
		request.setVersion("ss");
		 stub.getTerminalDetails(request);
		GetTerminalDetailsResponse response = stub.getTerminalDetails(request);
		System.out.println(response.getTerminals().getTerminal()[0].getStatus());
	}
}
